package com.ym.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ym.bean.User;
import com.ym.dao.UserDao;
import com.ym.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @auther gilgamesh_ym
 * @date 2021/3/17 19:52
 **/
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {
    /**
    * 注入用户dao
    **/
    private final UserDao userDao;

    public Integer insertUser(User user){
        return userDao.insert(user);
    }

    /**
    * 高级查询
    **/
    public List<User> list(User user){
        return userDao.selectList(new QueryWrapper<>(user));
    }

    /**
    * 根据id查询
    **/
    public User get(Integer id){
        return userDao.selectById(id);
    }

    /**
    * 通过id更新
    **/
    public Integer updateById(User user){
        return userDao.updateById(user);
    }

    /**
    * 通过id删除
    **/
    public Integer deleteById(Integer id){
        return userDao.deleteById(id);
    }

}
